package cn.cvs.controller;

import cn.cvs.pojo.SysUser;
import cn.cvs.service.SysUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class LoginController {
    @Resource
    SysUserService userService;

    @RequestMapping("/login")
    public String login(){
        return "doLogin";
    }

    @RequestMapping("/doLogin")
    public SysUser doLogin(@RequestParam("usrName") String usrName,@RequestParam("password") String pwd){
        List<SysUser> list = userService.findByUsrNameAndUsrPassword(usrName,pwd);
        if (null!=list && list.size()==1){
            return  list.get(0);
        }else{
            return null;
        }
    }
}
